#!/bin/bash

SCRIPT_DIR=$(cd `dirname $0` && pwd)
cd $SCRIPT_DIR

source config.mdnsd

rm -rf ./_install

if [ ! -f ${ARCHIVE} ]; then
    wget "${MAIN_URL}" -O "${ARCHIVE}" || exit 1
fi
unzip -o "${ARCHIVE}" || exit 1
cd "${BUILD_FOLDER}" || exit 1

./autogen.sh
./configure CC=arm-openwrt-linux-gcc \
    --prefix=$SCRIPT_DIR/_install \
    CFLAGS="-Os -mcpu=cortex-a7 -mfpu=neon-vfpv4 -I/opt/yi/toolchain-sunxi-musl/toolchain/include -L/opt/yi/toolchain-sunxi-musl/toolchain/lib" \
    AR=arm-openwrt-linux-ar \
    RANLIB=arm-openwrt-linux-ranlib \
    --host=arm \
    --disable-shared \
    --disable-doc \
    --without-mquery \
    --without-systemd \
    || exit 1
